const fs = require("fs");

// 读取file1
function readFile1() {
  return new Promise((resolve, reject) => {
    fs.readFile("./book/file1.txt", (err, data) => {
      if (err) return reject(err);
      resolve(data.toString());
    })
  })
}

// 读取file2
function readFile2() {
  return new Promise((resolve, reject) => {
    fs.readFile("./book/file2.txt", (err, data) => {
      if (err) return reject(err);
      resolve(data.toString());
    })
  })
}

// 读取file3
function readFile3() {
  return new Promise((resolve, reject) => {
    fs.readFile("./book/file3.txt", (err, data) => {
      if (err) return reject(err);
      resolve(data.toString());
    })
  })
}

// 声明一个async异步函数
async function main() {
  const res1 = await readFile1();
  const res2 = await readFile2();
  const res3 = await readFile3();
  console.log(res1);
  console.log(res2);
  console.log(res3);
}

main();